<?php
try{
	include '../ini.php';
    include '../classes/xl_categories.php';
    $dt_xl_category=new xl_category;
    $read_list=$dt_xl_category->read_list();
    $dt_smarty->assign('location',count($read_list));
    $dt_smarty->assign('read_list',$read_list);
	$contenForLayout=$dt_smarty->fetch('posts/categories_add.tpl');
	$dt_smarty->assign('contenForLayout',$contenForLayout);
	$dt_smarty->assign('titleForLayout','Thêm thể loại');
	$dt_smarty->display('layout/defaults.tpl');
    $dbh=NULL;
} catch(Exception $e){
	$_SESSION['msg']=$e->getMessage();
	$dbh=NULL;
}
function print_list($list,$id,$characters){
        foreach($list as $location):
            if($location['parent']==$id):
                if($location['type_category']==0){ 
                    $location['type_category']='Tin Tức';
                } else{
                    $location['type_category']='Thông Tin';
                }
                echo '<option value="'.$location['id'].'">'.$characters,$location['category_name'].'&nbsp;&nbsp;&nbsp;('.$location['type_category'].')'.'</option>';
                print_list($list,$location['id'],$characters.$characters);
            endif;
        endforeach;
}